import { VueConstructor } from 'vue'

import './css/index.scss'
import config from './config'

/** 控件选项列表 */
import { widgetOptions } from './widgets'
import { defineWidget } from './models/widget/option'

/** 组件 */
import * as components from './components'

/** 定义控件 */
widgetOptions.forEach(option => defineWidget(option.type, option))

/** `fdd-contract` 安装入口 */
const FddContract = {
  install(Vue: VueConstructor) {
    /** 全局安装组件 */
    Object.entries(components).forEach(([key, component]) => {
      Vue.component(component.name || key, component)
    })
  },

  /** 公共配置项 */
  config
}

export default FddContract

export * from './components'
export * from './types'
export * from './models'
export * from './utils'
